<?php if(isset($message)) : ?>
<?php echo $message; ?>
<?php else: ?>

<div class="row-fluid">
	<div class="span12">
		<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'booked-form',
			'enableAjaxValidation'=>false,
			'enableClientValidation' => true,            
			'htmlOptions'=>array(
				'class'=>'form-horizontal',
				),              
				)); ?>
				<div class="tabbable">
					<ul id="myTab" class="nav nav-tabs">
						<?php foreach($ticket as $key => $tickets) : ?>
							<li <?php if($key==0) echo 'class="active"' ?>>
								<a href="#tab_<?php echo $key; ?>" data-toggle="tab">
									<b class="blue">
										<?php echo $tickets->description_of_ticket; ?>
									</b>
								</a>
							</li>
						<?php endforeach;?>
					</ul>
					<div class="tab-content">
						<?php foreach($ticket as $key => $tickets) : ?>
							<div class="tab-pane <?php if($key==0) echo 'active' ?>"  id="tab_<?php echo $key; ?>">
								<dl id="dt-list-1" class="dl-horizontal">
									<dt>Ticket Code</dt>
									<dd><b class="blue"><?php echo $tickets->ticket_code; ?></b></dd>
									<dt>Ticket Description</dt>
									<dd><b class="blue"><?php echo $tickets->description_of_ticket; ?></b></dd>
									<dt>Price</dt>
									<dd><b class="red"><?php echo number_format($tickets->price); ?> VND / 1 Ticket</b></dd>
									<dt>Remain Quantity</dt>
									<dd>
									<?php $real_quantity = MyFunctionCustom::remain_quantity(null,$tickets->temp_quantity,$tickets->remain_quantity); ?>
                                            <?php if ($real_quantity < 20) : ?>
                                                <b class="red">
                                                    <?php echo $real_quantity;  ?>
                                                </b>
                                            <?php else : ?>
                                                <b class="blue"><?php echo $real_quantity; ?></b>
                                            <?php endif; ?>
                                    </dd>
								</dl>
								<div class="control-group">
			                        <label class="control-label">Quantity</label>
			                        <div class="controls">
			                        	<select class="price_details span2" name="BookedDetails[<?php echo $key; ?>][quantity]">
                                            <?php for($i = 0; $i <= 10; $i++) : ?>
                                                <?php if($i == 0) : ?>
                                                    <option selected="selected" value="<?php echo $i;  ?>"> <?php echo $i;  ?></option>
                                                <?php else : ?>
                                                    <option value="<?php echo $i;  ?>"> <?php echo $i;  ?></option>
                                                <?php endif;?>                                 
                                            <?php endfor; ?>
                                        </select>
			                            <input name="BookedDetails[<?php echo $key; ?>][ticket_id]" type="hidden" value="<?php echo $tickets->id; ?>" />
			                            <input name="BookedDetails[<?php echo $key; ?>][price]" type="hidden" value="<?php echo $tickets->price; ?>" />
			                        </div>
			                    </div>
			                    <div class="control-group">
			                        <div class="controls">
			                            <b class="red">Every seat position will be seperate with comma(,)</b>
			                        </div>
			                    </div>
			                    <div class="control-group">
			                        <label class="control-label">Seat</label>
			                        <div class="controls">
			                            <input name="BookedDetails[<?php echo $key; ?>][seat]" type="text" />
			                            <input name="BookedDetails[<?php echo $key; ?>][booked_id]" type="hidden" value="<?php echo $booked_id; ?>" />
			                        </div>
			                    </div>
			              		
							</div>
						<?php endforeach;?>
					</div>
				</div>

				<div class="form-actions">
					<a type="submit" class="btn btn-primary ajax-submit-btn">Save changes</a>
				</div>
	<?php $this->endWidget(); ?>
	</div>
</div>
<?php endif; ?>
<script type="text/javascript">
$('.ajax-submit-btn').bind('click', function() {
    $('.modal-body').empty();
    $('.modal-body').append('<div class="loading"><div style="width:134px;height:100px;margin:0 auto;padding-top: 10px;"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/frontend/images/ajaxloader.gif"></div></div>');
    $request.ajaxSubmit($(this), function(html) {

        window.location.reload();
    });
    return false;
});
</script>